package com.ymy.thinking.in.spring.dependency.injection;

import org.springframework.beans.factory.ObjectProvider;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * XML 配置元信息构造器注入示例
 *
 * @author Ringo
 * @date 2021/9/29 18:10
 */
public class XMLDependencyConstructorInjectionDemo {

    public static void main(String[] args) {
        String configLocation = "classpath:META-INFO/dependency-injection-constructor-configuration.xml";
        ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(configLocation);
        ObjectProvider<UserHolder> provider = applicationContext.getBeanProvider(UserHolder.class);
        provider.ifAvailable(System.out::println);
    }

}
